import { defineStore } from 'pinia';
import { deepClone } from 'src/utils/deepClone';

const menuItems = [
  {
    label: '项目集',
    icon: 'bi-layers-half',
    path_name: 'set-project',
  },

  {
    label: '项目信息',
    icon: '/svgs/projectName.svg',
    name: 'project',
    children: [
      {
        label: '项目概览',
        icon: 'svguse:#icon-overview',
        path_name: 'project-detail',
      },
      { label: '项目成员', icon: 'bi-people', path_name: 'project-member' },
      {
        label: '项目配置',
        icon: 'bi-people',
        path_name: 'project-configuration',
      },
    ],
  },
  {
    label: '数据中心',
    icon: '/svgs/dataCenter.svg',
    name: 'data',
    children: [
      //data-label-page
      { label: '数据集', icon: 'svguse:#icon-data', path_name: 'dataset' },
      { label: '数据处理', icon: 'svguse:#icon-data', path_name: 'data-process' },//功能内容不清晰，暂不显示
      // { label: '数据标注',icon: 'bi-tags',path_name: 'data-label'},
      { label: '数据标注', icon: 'bi-tags', path_name: 'dataAnnotations' },
      // { label: '数据特征库', icon: 'bi-tags', path_name: 'data-featureset' },
      { label: '特征库', icon: 'bi-tags', path_name: 'featureset' },
    ],
  },
  {
    label: '算法服务',
    icon: '/svgs/algorithmServices.svg',
    name: 'alg',
    children: [
      {
        label: '算法管理',
        icon: 'svguse:#icon-home',
        path_name: 'alg-manage'
      },
      {
        label: '公开市场',
        icon: 'svguse:#icon-quickly',
        path_name: 'public-market',
      }
    ],
  },
  {
    label: '模型服务',
    icon: '/svgs/modelService.svg',
    name: 'model',
    children: [
      {
        label: '训练作业',
        icon: 'bi-box',
        path_name: 'model-manage',
      },
      {
        label: '模型应用',
        icon: 'bi-shuffle',
        path_name: 'model-app',
      },
      {
        label: '模型部署',
        icon: 'bi-shuffle',
        path_name: 'model-deploy',
      },
    ],
  },
  // {
  //   label: '镜像服务',
  //   icon: 'svguse:#icon-dockerhub',
  //   name: 'mirror',
  //   children: [
  //     {
  //       label: '镜像仓库',
  //       icon: 'svguse:#icon-dockerhub',
  //       // path_name: 'mirror-repository',
  //     },
  //   ],
  // },
  {
    label: '设计器建模',
    icon: 'svgs/designerModeling.svg',
    children: [
      {
        label: '设计器',
        icon: 'svguse:#icon-quickly',
        path_name: 'designer-tool',
      },
      {
        label: '算子管理',
        icon: 'svguse:#icon-quickly',
        path_name: 'designer-manager',
      },
    ],
  },
  {
    label: '快速入门',
    icon: 'svgs/designerModeling.svg',
    children: [
      {
        label: '快速入门',
        icon: 'svguse:#icon-quickly',
        path_name: 'quick-start',
      }
    ],
  },
  // {
  //   label: '资源',
  //   icon: 'bi-folder2-open',
  //   name: 'cluster',
  //   children: [
  //     { label: '主机', icon: 'svguse:#icon-server', path_name: 'cluster-host' },
  //   ],
  // },
  // {
  //   label: '行业范例',
  //   icon: 'svguse:#icon-quickly',
  //   path_name: 'industry-example',
  // },
];

export const systemMenu = [
  {
    label: '系统模块',
    icon: 'svgs/systemManagement.svg',
    name: 'system',
    children: [
      {
        label: '用户管理',
        icon: 'svguse:#icon-data',
        path_name: 'system-user',
      },
      { label: '菜单管理', icon: 'bi-tags', path_name: 'system-menu' },
      // { label: '角色管理', icon: 'bi-tags', path_name: 'system-role' },
      { label: '日志管理', icon: 'bi-tags', path_name: 'system-dailyRecord' },
    ],
  },
];
export const useMenuStore = defineStore('menu-items', {
  state: () => ({
    menuItems: menuItems,
    showMenu: true,
    showBtn: true,
    copyMenu: menuItems,
    systemMenu: systemMenu,
    currentProject: {}, //进入具体项目
    allMenuList: [],
    projectManage: false,
  }),

  getters: {},
  actions: {
    setProjectManage(value: boolean) {
      this.projectManage = value;
    },
    setAllMenuList(arrayList: any) {
      this.allMenuList = arrayList;
    },
    setCurrentProject(obj: any) {
      this.currentProject = obj;
    },
    setShowMenu(value: boolean): void {
      this.showMenu = value;
      this.showBtn = value;
    },
    replaceMenuItems(): void {
      this.menuItems = this.systemMenu;
    },

    restoreMenuItems(): void {
      this.menuItems = deepClone(menuItems);
    },

    replaceCurrentMenuItem(obj: any): void {
      this.menuItems.splice(0, 1, obj);
    },

    addMenuItems(obj: any): void {
      this.menuItems.unshift(obj);
    },

    pushMenuItems(obj: any): void {
      this.menuItems.push(obj);
    },

    deleteMenuItems(): void {
      this.menuItems.shift();
    },
  },

  persist: {
    enabled: true, //不单独设置则为默认全开
    strategies: [
      {
        // 自定义存储方式，默认sessionStorage
        storage: sessionStorage,
        // 指定要持久化的数据
        paths: ['currentProject', 'menuItems', 'allMenuList', 'projectManage',],
      },
    ],
  },
});
